package com.ctshk.sapp.order.goods.controller;

import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.order.goods.service.IOrderCommodityCollectionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 商品订单收款明细 前端控制器
 * </p>
 *
 * @author 姜斌文
 * @since 2021-04-19
 */
@Api(value="商品收据", tags="商品收据")
@RestController
@RequestMapping("/order/commodity/collection")
public class OrderCommodityCollectionController extends BaseController {

    @DubboReference
    private IOrderCommodityCollectionService orderCommodityCollectionService;

    @ApiOperation(value = "商品订单票-取消订单-查询退款金额（减手续费）", notes = "商品订单票-取消订单-查询退款金额（减手续费）")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.QUERY, operTitle = "商品订单票-取消订单-查询退款金额（减手续费）", operDesc = "商品订单票-取消订单-查询退款金额（减手续费）")
    @GetMapping("/queryCollectionAmount/{id}")
    public Result queryCollectionAmount(@PathVariable("id") Long orderId) {
        Long userId = getCurrentUser(getRequest()).getId();
        return orderCommodityCollectionService.queryCollectionAmount(orderId, userId);
    }

    @ApiOperation(value = "商品订单票-订单操作-再次确认收款", notes = "商品订单票-订单操作-再次确认收款")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.UPDATE, operTitle = "商品订单票-订单操作-再次确认收款", operDesc = "商品订单票-订单操作-再次确认收款")
    @PostMapping("/reconfirm/{id}")
    public Result reconfirm(@PathVariable("id") Long id) {
        Long userId = getCurrentUser(getRequest()).getId();
        return orderCommodityCollectionService.reconfirm(id, userId);
    }
}
